package com.quanxiaoha.weblog.admin.controller;


import com.quanxiaoha.weblog.admin.model.vo.blogSetting.UpdateBlogSettingsReqVO;
import com.quanxiaoha.weblog.admin.service.AdminBlogSettingService;
import com.quanxiaoha.weblog.common.aspect.ApiOperationLog;
import com.quanxiaoha.weblog.common.utils.Response;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/admin/blog/setting")
@Api(tags = "博客设置模块")
public class AdminBlogSettingController {

    @Autowired
    private AdminBlogSettingService adminBlogSettingService;

    @PostMapping("/update")
    @ApiOperation(value = "更新博客设置")
    @ApiOperationLog(description = "更新博客设置")
    public Response updateBlogSettings(@RequestBody @Validated UpdateBlogSettingsReqVO updateBlogSettingsReqVO) {
        return adminBlogSettingService.updateSettings(updateBlogSettingsReqVO);
    }


    @GetMapping("/detail/{id}")
    @ApiOperation(value = "根据id查看博客设置")
    @ApiOperationLog(description = "根据id查看博客设置")
    public Response getSettingDetails(@PathVariable("id") Long id) {
        return adminBlogSettingService.getDetail(id);
    }
}
